package la.iok.hzsvn.lewin.movie.cloud.model;

import java.util.Objects;

/**
 * 获取验证码参数
 */
public class PhoneCodeParam {
    /**
     * 注册操作
     */
    public static final int OPERATION_REG = 1;
    /**
     * 登录操作
     */
    public static final int OPERATION_LOGIN = 2;
    /**
     * 修改账号操作
     */
    public static final int OPERATION_MODIFY_ACCOUNT = 3;
    /**
     * 通过手机验证码修改密码。目前只能在PAD上修改
     */
    public static final int OPERATION_MODIFY_PASSWORD = 4;
    /**
     * 获取验证码的手机号
     */
    private String phoneNumber;
    /**
     * 客户端设备码.如果是未登录时必须要有
     */
    private String code;
    /**
     * 操作类型。1为注册,2为登录（在uuid不为空的时候,如果登录用户不存在,就注册，此时注册为玩家）,3为修改账号
     */
    private int operation;
    /**
     * 根据二维码的uuid获取手机验证码。需要设备码有值。主要用于玩家通过扫描开本记录二维码进行注册或者登录
     */
    private String uuid;

    public PhoneCodeParam() {
    }

    public PhoneCodeParam(String phoneNumber, String code) {
        this.phoneNumber = phoneNumber;
        this.code = code;
    }

    public PhoneCodeParam(String phoneNumber, String code, int operation) {
        this.phoneNumber = phoneNumber;
        this.code = code;
        this.operation = operation;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getOperation() {
        return operation;
    }

    public void setOperation(int operation) {
        this.operation = operation;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    /**
     * 是否注册操作
     * @return 是注册操作返回true,否则false
     */
    public boolean operationReg(){
        return OPERATION_REG == operation;
    }

    /**
     * 是否登录操作
     * @return 是登录操作返回true,否则返回false
     */
    public boolean operationLogin(){
        return OPERATION_LOGIN == operation;
    }

    /**
     * 是否账号修改操作
     * @return 是账号修改返回true,否则false
     */
    public boolean operationModifyAccount() {
        return OPERATION_MODIFY_ACCOUNT == operation;
    }

    /**
     * 是否修改密码操作
     * @return 是密码修改操作返回true,否则false
     */
    public boolean operationModifyPassword(){
        return OPERATION_MODIFY_PASSWORD == operation;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PhoneCodeParam param = (PhoneCodeParam) o;
        return operation == param.operation && Objects.equals(phoneNumber, param.phoneNumber) && Objects.equals(code, param.code);
    }

    @Override
    public int hashCode() {
        return Objects.hash(phoneNumber, code, operation);
    }
}
